home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / andere sprachen / perl5 / perl5.002 / lib / extutils / makemaker.pm < prev    next >
Encoding:
Perl POD Document  |  1996-02-27  |  51.9 KB  |  1,781 lines

  1. package main;
  2. use vars qw(%att);
  3.  
  4. # $Id: MakeMaker.pm,v 1.174 1996/02/06 17:03:12 k Exp $
  5.  
  6. package ExtUtils::MakeMaker::TieAtt;
  7. # this package will go away again, when we don't have modules around
  8. # anymore that import %att It ties an empty %att and records in which
  9. # object this %att was tied. FETCH and STORE return/store-to the
  10. # appropriate value from %$self
  11.  
  12. # the warndirectuse method warns if somebody calls MM->something. It
  13. # has nothing to do with the tie'd %att.
  14.  
  15. $Enough_limit = 5;
  16.  
  17. sub TIEHASH {
  18.     bless { SECRETHASH => $_[1]};
  19. }
  20.  
  21. sub FETCH {
  22.     print "Warning (non-fatal): Importing of %att is deprecated [$_[1]]
  23.     use \$self instead\n" unless ++$Enough>$Enough_limit;
  24.     print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit;
  25.     $_[0]->{SECRETHASH}->{$_[1]};
  26. }
  27.  
  28. sub STORE {
  29.     print "Warning (non-fatal): Importing of %att is deprecated [$_[1]][$_[2]]
  30.     use \$self instead\n" unless ++$Enough>$Enough_limit;
  31.     print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit;
  32.     $_[0]->{SECRETHASH}->{$_[1]} = $_[2];
  33. }
  34.  
  35. sub FIRSTKEY {
  36.     print "Warning (non-fatal): Importing of %att is deprecated [FIRSTKEY]
  37.     use \$self instead\n" unless ++$Enough>$Enough_limit;
  38.     print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit;
  39.     each %{$_[0]->{SECRETHASH}};
  40. }
  41.  
  42. sub NEXTKEY {
  43.     each %{$_[0]->{SECRETHASH}};
  44. }
  45.  
  46. sub DESTROY {
  47. }
  48.  
  49. sub warndirectuse {
  50.     my($caller) = @_;
  51.     return if $Enough>$Enough_limit;
  52.     print STDOUT "Warning (non-fatal): Direct use of class methods deprecated; use\n";
  53.     my($method) = $caller =~ /.*:(\w+)$/;
  54.     print STDOUT
  55. '        my $self = shift;
  56.         $self->MM::', $method, "();
  57.     instead\n";
  58.     print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n"
  59.     if ++$Enough==$Enough_limit;
  60. }
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. package ExtUtils::MakeMaker;
  68.  
  69. $Version = $VERSION = "5.21";
  70. $Version_OK = "5.05";    # Makefiles older than $Version_OK will die
  71.             # (Will be checked from MakeMaker version 4.13 onwards)
  72. ($Revision = substr(q$Revision: 1.174 $, 10)) =~ s/\s+$//;
  73.  
  74.  
  75.  
  76. use Config;
  77. use Carp;
  78. use Cwd;
  79. require Exporter;
  80. require ExtUtils::Manifest;
  81. {
  82.     # Current (5.21) FileHandle doesn't work with miniperl, so we roll our own
  83.     # that's all copy & paste code from FileHandle.pm, version of perl5.002b3
  84.     package FileHandle;
  85.     use Symbol;
  86.     sub new {
  87.     @_ >= 1 && @_ <= 3 or croak('usage: new FileHandle [FILENAME [,MODE]]');
  88.     my $class = shift;
  89.     my $fh = gensym;
  90.     if (@_) {
  91.         FileHandle::open($fh, @_)
  92.         or return undef;
  93.     }
  94.     bless $fh, $class;
  95.     }
  96.     sub open {
  97.     @_ >= 2 && @_ <= 4 or croak('usage: $fh->open(FILENAME [,MODE [,PERMS]])');
  98.     my ($fh, $file) = @_;
  99.     if (@_ > 2) {
  100.         my ($mode, $perms) = @_[2, 3];
  101.         if ($mode =~ /^\d+$/) {
  102.         defined $perms or $perms = 0666;
  103.         return sysopen($fh, $file, $mode, $perms);
  104.         }
  105.         $file = "./" . $file unless $file =~ m#^/#;
  106.         $file = _open_mode_string($mode) . " $file\0";
  107.     }
  108.     open($fh, $file);
  109.     }
  110.     sub close {
  111.     @_ == 1 or croak('usage: $fh->close()');
  112.     close($_[0]);
  113.     }
  114. }
  115.  
  116. use vars qw(
  117.         $VERSION $Version_OK $Revision
  118.         $Verbose %MM_Sections
  119.         @MM_Sections %Recognized_Att_Keys @Get_from_Config
  120.         %Prepend_dot_dot %Config @Parent %NORMAL_INC
  121.         $Setup_done
  122.        );
  123. #use strict qw(refs);
  124.  
  125. eval {require DynaLoader;};    # Get mod2fname, if defined. Will fail
  126.                                 # with miniperl.
  127.  
  128. #
  129. # Set up the inheritance before we pull in the MM_* packages, because they
  130. # import variables and functions from here
  131. #
  132. @ISA = qw(Exporter);
  133. @EXPORT = qw(&WriteMakefile &writeMakefile $Verbose &prompt);
  134. @EXPORT_OK = qw($VERSION &Version_check &help &neatvalue &mkbootstrap &mksymlists
  135.         $Version %att);  ## Import of %att is deprecated, please use OO features!
  136.         # $Version in mixed case will go away!
  137.  
  138. #
  139. # Dummy package MM inherits actual methods from OS-specific
  140. # default packages.  We use this intermediate package so
  141. # MY::XYZ->func() can call MM->func() and get the proper
  142. # default routine without having to know under what OS
  143. # it's running.
  144. #
  145. @MM::ISA = qw[ExtUtils::MM_Unix ExtUtils::Liblist ExtUtils::MakeMaker];
  146.  
  147. #
  148. # Setup dummy package:
  149. # MY exists for overriding methods to be defined within
  150. #
  151. {
  152.     package MY;
  153.     @ISA = qw(MM);
  154. }
  155.  
  156. {
  157.     package MM;
  158.     # From somwhere they will want to inherit DESTROY
  159.     sub DESTROY {}
  160. }
  161.  
  162. #
  163. # Now we can can pull in the friends
  164. # Since they will require us back, we would better prepare the needed
  165. # data _before_ we require them.
  166. #
  167. $Is_VMS = ($Config{osname} eq 'VMS');
  168. $Is_OS2 = ($Config{osname} =~ m|^os/?2$|i);
  169.  
  170. require ExtUtils::MM_Unix;
  171. if ($Is_VMS) {
  172.     require ExtUtils::MM_VMS;
  173.     require VMS::Filespec;
  174.     import VMS::Filespec '&vmsify';
  175. }
  176. if ($Is_OS2) {
  177.     require ExtUtils::MM_OS2;
  178. }
  179.  
  180. %NORMAL_INC = %INC;
  181. # package name for the classes into which the first object will be blessed
  182. $PACKNAME = "PACK000";
  183.  
  184.  #####
  185. #     #  #    #  #####
  186. #        #    #  #    #
  187.  #####   #    #  #####
  188.       #  #    #  #    #
  189. #     #  #    #  #    #
  190.  #####    ####   #####
  191.  
  192.  
  193. #
  194. # MakeMaker serves currently (v 5.20) only for two purposes:
  195. # Version_Check, and WriteMakefile. For WriteMakefile SelfLoader
  196. # doesn't buy us anything. But for Version_Check we win with
  197. # SelfLoader more than a second.
  198. #
  199. # The only subroutine we do not SelfLoad is Version_Check because it's
  200. # called so often. Loading this minimum still requires 1.2 secs on my
  201. # Indy :-(
  202. #
  203.  
  204. sub Version_check {
  205.     my($checkversion) = @_;
  206.     die "Your Makefile was built with ExtUtils::MakeMaker v $checkversion.
  207. Current Version is $ExtUtils::MakeMaker::VERSION. There have been considerable
  208. changes in the meantime.
  209. Please rerun 'perl Makefile.PL' to regenerate the Makefile.\n"
  210.     if $checkversion < $Version_OK;
  211.     printf STDOUT "%s %s %s %s.\n", "Makefile built with ExtUtils::MakeMaker v",
  212.     $checkversion, "Current Version is", $VERSION
  213.     unless $checkversion == $VERSION;
  214. }
  215.  
  216. # We don't selfload this, because chdir sometimes has problems
  217. sub eval_in_subdirs {
  218.     my($self) = @_;
  219.     my($dir);
  220. #    print "Starting to wade through directories:\n";
  221. #    print join "\n", @{$self->{DIR}}, "\n";
  222.     my $pwd = cwd();
  223.  
  224.     # As strange things happened twice in the history of MakeMaker to $self->{DIR},
  225.     # lets be careful, maybe it helps some:
  226. #    my(@copy_of_DIR) = @{$self->{DIR}};
  227. #    my %copy;
  228. #    @copy{@copy_od_DIR} = (1) x @copy_of_DIR;
  229.  
  230.     # with Tk-9.02 these give me as third directory "1":
  231.     # foreach $dir (@($self->{DIR}){
  232.     # foreach $dir (@copy_of_DIR){
  233.  
  234.     # this gives mi as third directory a core dump:
  235.     # while ($dir = shift @copy_of_DIR){
  236.  
  237.     # this finishes the loop immediately:
  238. #     foreach $dir (keys %copy){
  239. #       print "Next to come: $dir\n";
  240. #       chdir $dir or die "Couldn't change to directory $dir: $!";
  241. #       package main;
  242. #       my $fh = new FileHandle;
  243. #       $fh->open("Makefile.PL") or carp("Couldn't open Makefile.PL in $dir");
  244. #       my $eval = join "", <$fh>;
  245. #       $fh->close;
  246. #       eval $eval;
  247. #       warn "WARNING from evaluation of $dir/Makefile.PL: $@" if $@;
  248. #       chdir $pwd or die "Couldn't change to directory $pwd: $!";
  249. #     }
  250.  
  251.  
  252.     # So this did the trick (did it?)
  253.     foreach $dir (@{$self->{DIR}}){
  254. #    print "Next to come: $dir\n";
  255.     my($abs) = $self->catdir($pwd,$dir);
  256.     $self->eval_in_x($abs);
  257.     }
  258.  
  259.     chdir $pwd;
  260.  
  261. #    print "Proudly presenting you self->{DIR}:\n";
  262. #    print join "\n", @{$self->{DIR}}, "\n";
  263.  
  264. }
  265.  
  266. sub eval_in_x {
  267.     my($self,$dir) = @_;
  268.     package main;
  269.     chdir $dir or carp("Couldn't change to directory $dir: $!");
  270.     my $fh = new FileHandle;
  271.     $fh->open("Makefile.PL") or carp("Couldn't open Makefile.PL in $dir");
  272.     my $eval = join "", <$fh>;
  273.     $fh->close;
  274.     eval $eval;
  275.     warn "WARNING from evaluation of $dir/Makefile.PL: $@" if $@;
  276. }
  277.  
  278. # use SelfLoader;
  279. # sub ExtUtils::MakeMaker::full_setup ;
  280. # sub ExtUtils::MakeMaker::attrib_help ;
  281. # sub ExtUtils::MakeMaker::writeMakefile ;
  282. # sub ExtUtils::MakeMaker::WriteMakefile ;
  283. # sub ExtUtils::MakeMaker::new ;
  284. # sub ExtUtils::MakeMaker::check_manifest ;
  285. # sub ExtUtils::MakeMaker::parse_args ;
  286. # sub ExtUtils::MakeMaker::check_hints ;
  287. # sub ExtUtils::MakeMaker::mv_all_methods ;
  288. # sub ExtUtils::MakeMaker::prompt ;
  289. # sub ExtUtils::MakeMaker::help ;
  290. # sub ExtUtils::MakeMaker::skipcheck ;
  291. # sub ExtUtils::MakeMaker::flush ;
  292. # sub ExtUtils::MakeMaker::mkbootstrap ;
  293. # sub ExtUtils::MakeMaker::mksymlists ;
  294. # sub ExtUtils::MakeMaker::neatvalue ;
  295. # sub ExtUtils::MakeMaker::selfdocument ;
  296.  
  297. # 1;
  298.  
  299. # __DATA__
  300.  
  301. #
  302. # We're done with inheritance setup. As we have two frequently called
  303. # things: Check_Version() and mod_install(), we want to reduce startup
  304. # time. Only WriteMakefile needs all the power here. 
  305. #
  306.  
  307. sub full_setup {
  308.     $Verbose ||= 0;
  309.     $^W=1;
  310.     $SIG{__WARN__} = sub {
  311.     $_[0] =~ /^Use of uninitialized value/ && return;
  312.     $_[0] =~ /used only once/ && return;
  313.     $_[0] =~ /^Subroutine\s+[\w:]+\s+redefined/ && return;
  314.     warn @_;
  315.     };
  316.  
  317.     @MM_Sections = 
  318.     qw(
  319.     post_initialize const_config constants const_loadlibs
  320.     const_cccmd tool_autosplit tool_xsubpp tools_other dist macro
  321.     depend post_constants pasthru c_o xs_c xs_o top_targets
  322.     linkext dlsyms dynamic dynamic_bs dynamic_lib static
  323.     static_lib installpm manifypods processPL installbin subdirs
  324.     clean realclean dist_basics dist_core dist_dir dist_test
  325.     dist_ci install force perldepend makefile staticmake test
  326.     postamble selfdocument
  327.       ); # loses section ordering
  328.  
  329.     @MM_Sections{@MM_Sections} = {} x @MM_Sections;
  330.  
  331.     # All sections are valid keys.
  332.     %Recognized_Att_Keys = %MM_Sections;
  333.  
  334.     # we will use all these variables in the Makefile
  335.     @Get_from_Config = 
  336.     qw(
  337.        ar cc cccdlflags ccdlflags dlext dlsrc ld lddlflags ldflags libc
  338.        lib_ext obj_ext ranlib sitelibexp sitearchexp so
  339.       );
  340.  
  341.     my $item;
  342.     foreach $item (split(/\n/,attrib_help())){
  343.     next unless $item =~ m/^=item\s+(\w+)\s*$/;
  344.     $Recognized_Att_Keys{$1} = $2;
  345.     print "Attribute '$1' => '$2'\n" if ($Verbose >= 2);
  346.     }
  347.     foreach $item (@Get_from_Config) {
  348.     $Recognized_Att_Keys{uc $item} = $Config{$item};
  349.     print "Attribute '\U$item\E' => '$Config{$item}'\n"
  350.         if ($Verbose >= 2);
  351.     }
  352.  
  353.     #
  354.     # When we pass these through to a Makefile.PL in a subdirectory, we prepend
  355.     # "..", so that all files to be installed end up below ./blib
  356.     #
  357.     %Prepend_dot_dot = 
  358.     qw(
  359.        INST_LIB 1 INST_ARCHLIB 1 INST_EXE 1 MAP_TARGET 1 INST_MAN1DIR 1 INST_MAN3DIR 1
  360.        PERL_SRC 1 PERL 1 FULLPERL 1
  361.       );
  362.  
  363. }
  364.  
  365. sub attrib_help {
  366.     return $Attrib_Help if $Attrib_Help;
  367.     my $switch = 0;
  368.     my $help = "";
  369.     my $line;
  370.     while ($line = <DATA>) {
  371.     $switch ||= $line =~ /^=item C\s*$/;
  372.     next unless $switch;
  373.     last if $line =~ /^=cut/;
  374.     $help .= $line;
  375.     }
  376. #    close DATA;
  377.     $Attrib_Help = $help;
  378. }
  379.  
  380. sub writeMakefile {
  381.     die <<END;
  382.  
  383. The extension you are trying to build apparently is rather old and
  384. most probably outdated. We detect that from the fact, that a
  385. subroutine "writeMakefile" is called, and this subroutine is not
  386. supported anymore since about October 1994.
  387.  
  388. Please contact the author or look into CPAN (details about CPAN can be
  389. found in the FAQ and at http:/www.perl.com) for a more recent version
  390. of the extension. If you're really desperate, you can try to change
  391. the subroutine name from writeMakefile to WriteMakefile and rerun
  392. 'perl Makefile.PL', but you're most probably left alone, when you do
  393. so.
  394.  
  395. The MakeMaker team
  396.  
  397. END
  398. }
  399.  
  400. sub WriteMakefile {
  401.     Carp::croak "WriteMakefile: Need even number of args" if @_ % 2;
  402.     my %att = @_;
  403.     MM->new(\%att)->flush;
  404. }
  405.  
  406. sub new {
  407.     my($class,$self) = @_;
  408.     full_setup() unless $Setup_done++;
  409.  
  410.     my($key);
  411.  
  412.     print STDOUT "MakeMaker (v$VERSION)\n" if $Verbose;
  413.     if (-f "MANIFEST" && ! -f "Makefile"){
  414.     check_manifest();
  415.     }
  416.  
  417.     $self = {} unless (defined $self);
  418.  
  419.     check_hints($self);
  420.  
  421.     my(%initial_att) = %$self; # record initial attributes
  422.  
  423.     if (defined $self->{CONFIGURE}) {
  424.     if (ref $self->{CONFIGURE} eq 'CODE') {
  425.         $self = { %$self, %{&{$self->{CONFIGURE}}}};
  426.     } else {
  427.         croak "Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n";
  428.     }
  429.     }
  430.  
  431.     # This is for old Makefiles written pre 5.00, will go away
  432.     if ( Carp::longmess("") =~ /runsubdirpl/s ){
  433.     #$self->{Correct_relativ_directories}++;
  434.     carp("WARNING: Please rerun 'perl Makefile.PL' to regenerate your Makefiles\n");
  435.     } else {
  436.     $self->{Correct_relativ_directories}=0;
  437.     }
  438.  
  439.     my $class = ++$PACKNAME;
  440.     {
  441. #    no strict;
  442.     print "Blessing Object into class [$class]\n" if $Verbose>=2;
  443.     mv_all_methods("MY",$class);
  444.     bless $self, $class;
  445.     push @Parent, $self;
  446.     @{"$class\:\:ISA"} = 'MM';
  447.     }
  448.  
  449.     if (defined $Parent[-2]){
  450.     $self->{PARENT} = $Parent[-2];
  451.     my $key;
  452.     for $key (keys %Prepend_dot_dot) {
  453.         next unless defined $self->{PARENT}{$key};
  454.         $self->{$key} = $self->{PARENT}{$key};
  455.         $self->{$key} = $self->catdir("..",$self->{$key})
  456.         unless $self->{$key} =~ m!^/!;
  457.     }
  458.     $self->{PARENT}->{CHILDREN}->{$class} = $self if $self->{PARENT};
  459.     } else {
  460.     parse_args($self,@ARGV);
  461.     }
  462.  
  463.     $self->{NAME} ||= $self->guess_name;
  464.  
  465.     ($self->{NAME_SYM} = $self->{NAME}) =~ s/\W+/_/g;
  466.  
  467.     $self->init_main();
  468.  
  469.     if (! $self->{PERL_SRC} ) {
  470.     my($pthinks) = $INC{'Config.pm'};
  471.     $pthinks = vmsify($pthinks) if $Is_VMS;
  472.     if ($pthinks ne $self->catfile($Config{archlibexp},'Config.pm')){
  473.         $pthinks =~ s!/Config\.pm$!!;
  474.         $pthinks =~ s!.*/!!;
  475.         print STDOUT <<END;
  476. Your perl and your Config.pm seem to have different ideas about the architecture
  477. they are running on.
  478. Perl thinks: [$pthinks]
  479. Config says: [$Config{archname}]
  480. This may or may not cause problems. Please check your installation of perl if you
  481. have problems building this extension.
  482. END
  483.     }
  484.     }
  485.  
  486.     $self->init_dirscan();
  487.     $self->init_others();
  488.  
  489.     push @{$self->{RESULT}}, <<END;
  490. # This Makefile is for the $self->{NAME} extension to perl.
  491. #
  492. # It was generated automatically by MakeMaker version
  493. # $VERSION (Revision: $Revision) from the contents of
  494. # Makefile.PL. Don't edit this file, edit Makefile.PL instead.
  495. #
  496. #    ANY CHANGES MADE HERE WILL BE LOST!
  497. #
  498. #   MakeMaker Parameters:
  499. END
  500.  
  501.     foreach $key (sort keys %initial_att){
  502.     my($v) = neatvalue($initial_att{$key});
  503.     $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
  504.     $v =~ tr/\n/ /s;
  505.     push @{$self->{RESULT}}, "#    $key => $v";
  506.     }
  507.  
  508.     # turn the SKIP array into a SKIPHASH hash
  509.     my (%skip,$skip);
  510.     for $skip (@{$self->{SKIP} || []}) {
  511.     $self->{SKIPHASH}{$skip} = 1;
  512.     }
  513.  
  514.     # We run all the subdirectories now. They don't have much to query
  515.     # from the parent, but the parent has to query them: if they need linking!
  516.     unless ($self->{NORECURS}) {
  517.     $self->eval_in_subdirs if @{$self->{DIR}};
  518.     }
  519.  
  520.     tie %::att, ExtUtils::MakeMaker::TieAtt, $self;
  521.     my $section;
  522.     foreach $section ( @MM_Sections ){
  523.     print "Processing Makefile '$section' section\n" if ($Verbose >= 2);
  524.     my($skipit) = $self->skipcheck($section);
  525.     if ($skipit){
  526.         push @{$self->{RESULT}}, "\n# --- MakeMaker $section section $skipit.";
  527.     } else {
  528.         my(%a) = %{$self->{$section} || {}};
  529.         push @{$self->{RESULT}}, "\n# --- MakeMaker $section section:";
  530.         push @{$self->{RESULT}}, "# " . join ", ", %a if $Verbose && %a;
  531.         push @{$self->{RESULT}}, $self->nicetext($self->$section( %a ));
  532.     }
  533.     }
  534.  
  535.     push @{$self->{RESULT}}, "\n# End.";
  536.     pop @Parent;
  537.  
  538.     $self;
  539. }
  540.  
  541. sub check_manifest {
  542.     print STDOUT "Checking if your kit is complete...\n";
  543.     $ExtUtils::Manifest::Quiet=$ExtUtils::Manifest::Quiet=1; #avoid warning
  544.     my(@missed)=ExtUtils::Manifest::manicheck();
  545.     if (@missed){
  546.     print STDOUT "Warning: the following files are missing in your kit:\n";
  547.     print "\t", join "\n\t", @missed;
  548.     print STDOUT "\n";
  549.     print STDOUT "Please inform the author.\n";
  550.     } else {
  551.     print STDOUT "Looks good\n";
  552.     }
  553. }
  554.  
  555. sub parse_args{
  556.     my($self, @args) = @_;
  557.     foreach (@args){
  558.     unless (m/(.*?)=(.*)/){
  559.         help(),exit 1 if m/^help$/;
  560.         ++$Verbose if m/^verb/;
  561.         next;
  562.     }
  563.     my($name, $value) = ($1, $2);
  564.     if ($value =~ m/^~(\w+)?/){ # tilde with optional username
  565.         $value =~ s [^~(\w*)]
  566.         [$1 ?
  567.          ((getpwnam($1))[7] || "~$1") :
  568.          (getpwuid($>))[7]
  569.          ]ex;
  570.     }
  571.     # This may go away, in mid 1996
  572.     if ($self->{Correct_relativ_directories}){
  573.         $value = $self->catdir("..",$value)
  574.         if $Prepend_dot_dot{$name} && ! $value =~ m!^/!;
  575.     }
  576.     $self->{uc($name)} = $value;
  577.     }
  578.     # This may go away, in mid 1996
  579.     delete $self->{Correct_relativ_directories};
  580.  
  581.     # catch old-style 'potential_libs' and inform user how to 'upgrade'
  582.     if (defined $self->{potential_libs}){
  583.     my($msg)="'potential_libs' => '$self->{potential_libs}' should be";
  584.     if ($self->{potential_libs}){
  585.         print STDOUT "$msg changed to:\n\t'LIBS' => ['$self->{potential_libs}']\n";
  586.     } else {
  587.         print STDOUT "$msg deleted.\n";
  588.     }
  589.     $self->{LIBS} = [$self->{potential_libs}];
  590.     delete $self->{potential_libs};
  591.     }
  592.     # catch old-style 'ARMAYBE' and inform user how to 'upgrade'
  593.     if (defined $self->{ARMAYBE}){
  594.     my($armaybe) = $self->{ARMAYBE};
  595.     print STDOUT "ARMAYBE => '$armaybe' should be changed to:\n",
  596.             "\t'dynamic_lib' => {ARMAYBE => '$armaybe'}\n";
  597.     my(%dl) = %{$self->{dynamic_lib} || {}};
  598.     $self->{dynamic_lib} = { %dl, ARMAYBE => $armaybe};
  599.     delete $self->{ARMAYBE};
  600.     }
  601.     if (defined $self->{LDTARGET}){
  602.     print STDOUT "LDTARGET should be changed to LDFROM\n";
  603.     $self->{LDFROM} = $self->{LDTARGET};
  604.     delete $self->{LDTARGET};
  605.     }
  606.     # Turn a DIR argument on the command line into an array
  607.     if (defined $self->{DIR} && ref \$self->{DIR} eq 'SCALAR') {
  608.     # So they can choose from the command line, which extensions they want
  609.     # the grep enables them to have some colons too much in case they
  610.     # have to build a list with the shell
  611.     $self->{DIR} = [grep $_, split ":", $self->{DIR}];
  612.     }
  613.     my $mmkey;
  614.     foreach $mmkey (sort keys %$self){
  615.     print STDOUT "    $mmkey => ", neatvalue($self->{$mmkey}), "\n" if $Verbose;
  616.     print STDOUT "'$mmkey' is not a known MakeMaker parameter name.\n"
  617.         unless exists $Recognized_Att_Keys{$mmkey};
  618.     }
  619. }
  620.  
  621. sub check_hints {
  622.     my($self) = @_;
  623.     # We allow extension-specific hints files.
  624.  
  625.     return unless -d "hints";
  626.  
  627.     # First we look for the best hintsfile we have
  628.     my(@goodhints);
  629.     my($hint)="$Config{osname}_$Config{osvers}";
  630.     $hint =~ s/\./_/g;
  631.     $hint =~ s/_$//;
  632.     return unless $hint;
  633.  
  634.     # Also try without trailing minor version numbers.
  635.     while (1) {
  636.     last if -f "hints/$hint.pl";      # found
  637.     } continue {
  638.     last unless $hint =~ s/_[^_]*$//; # nothing to cut off
  639.     }
  640.     return unless -f "hints/$hint.pl";    # really there
  641.  
  642.     # execute the hintsfile:
  643.     my $fh = new FileHandle;
  644.     $fh->open("hints/$hint.pl");
  645.     @goodhints = <$fh>;
  646.     $fh->close;
  647.     print STDOUT "Processing hints file hints/$hint.pl\n";
  648.     eval join('',@goodhints);
  649.     print STDOUT $@ if $@;
  650. }
  651.  
  652. sub mv_all_methods {
  653.     my($from,$to) = @_;
  654.     my($method);
  655.     my($symtab) = \%{"${from}::"};
  656. #    no strict;
  657.  
  658.     # Here you see the *current* list of methods that are overridable
  659.     # from Makefile.PL via MY:: subroutines. As of VERSION 5.07 I'm
  660.     # still trying to reduce the list to some reasonable minimum --
  661.     # because I want to make it easier for the user. A.K.
  662.  
  663.     foreach $method (@MM_Sections, qw[ dir_target
  664. fileparse fileparse_set_fstype installpm_x libscan makeaperl
  665. mksymlists needs_linking subdir_x test_via_harness
  666. test_via_script writedoc ]) {
  667.  
  668.     # We cannot say "next" here. Nick might call MY->makeaperl
  669.     # which isn't defined right now
  670.  
  671.     # next unless defined &{"${from}::$method"};
  672.  
  673.     *{"${to}::$method"} = \&{"${from}::$method"};
  674.  
  675.     # delete would do, if we were sure, nobody ever called
  676.     # MY->makeaperl directly
  677.  
  678.     # delete $symtab->{$method};
  679.  
  680.     # If we delete a method, then it will be undefined and cannot
  681.     # be called.  But as long as we have Makefile.PLs that rely on
  682.     # %MY:: being intact, we have to fill the hole with an
  683.     # inheriting method:
  684.  
  685.     eval "package MY; sub $method {local *$method; shift->MY::$method(\@_); }";
  686.  
  687.     }
  688.  
  689.     # We have to clean out %INC also, because the current directory is
  690.     # changed frequently and Graham Barr prefers to get his version
  691.     # out of a History.pl file which is "required" so woudn't get
  692.     # loaded again in another extension requiring a History.pl
  693.  
  694.     my $inc;
  695.     foreach $inc (keys %INC) {
  696.     next if $NORMAL_INC{$inc};
  697.     #warn "***$inc*** deleted";
  698.     delete $INC{$inc};
  699.     }
  700.  
  701. }
  702.  
  703. sub prompt {
  704.     my($mess,$def)=@_;
  705.     BEGIN { $ISA_TTY = -t STDIN && -t STDOUT }
  706.     Carp::confess("prompt function called without an argument") unless defined $mess;
  707.     $def = "" unless defined $def;
  708.     my $dispdef = "[$def] ";
  709.     my $ans;
  710.     if ($ISA_TTY) {
  711.     local $|=1;
  712.     print "$mess $dispdef";
  713.     chop($ans = <STDIN>);
  714.     }
  715.     return $ans if defined $ans;
  716.     return $def;
  717. }
  718.  
  719. sub help {print &attrib_help, "\n";}
  720.  
  721. sub skipcheck{
  722.     my($self) = shift;
  723.     my($section) = @_;
  724.     if ($section eq 'dynamic') {
  725.     print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ",
  726.     "in skipped section 'dynamic_bs'\n"
  727.             if $self->{SKIPHASH}{dynamic_bs} && $Verbose;
  728.         print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ",
  729.     "in skipped section 'dynamic_lib'\n"
  730.             if $self->{SKIPHASH}{dynamic_lib} && $Verbose;
  731.     }
  732.     if ($section eq 'dynamic_lib') {
  733.         print STDOUT "Warning (non-fatal): Target '\$(INST_DYNAMIC)' depends on ",
  734.     "targets in skipped section 'dynamic_bs'\n"
  735.             if $self->{SKIPHASH}{dynamic_bs} && $Verbose;
  736.     }
  737.     if ($section eq 'static') {
  738.         print STDOUT "Warning (non-fatal): Target 'static' depends on targets ",
  739.     "in skipped section 'static_lib'\n"
  740.             if $self->{SKIPHASH}{static_lib} && $Verbose;
  741.     }
  742.     return 'skipped' if $self->{SKIPHASH}{$section};
  743.     return '';
  744. }
  745.  
  746. sub flush {
  747.     my $self = shift;
  748.     my($chunk);
  749.     my $fh = new FileHandle;
  750.     print STDOUT "Writing $self->{MAKEFILE} for $self->{NAME}\n";
  751.  
  752.     unlink($self->{MAKEFILE}, "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : '');
  753.     $fh->open(">MakeMaker.tmp") or die "Unable to open MakeMaker.tmp: $!";
  754.  
  755.     for $chunk (@{$self->{RESULT}}) {
  756.     print $fh "$chunk\n";
  757.     }
  758.  
  759.     $fh->close;
  760.     my($finalname) = $self->{MAKEFILE};
  761.     rename("MakeMaker.tmp", $finalname);
  762.     chmod 0644, $finalname unless $Is_VMS;
  763.     system("$Config::Config{eunicefix} $finalname") unless $Config::Config{eunicefix} eq ":";
  764. }
  765.  
  766. # The following mkbootstrap() is only for installations that are calling
  767. # the pre-4.1 mkbootstrap() from their old Makefiles. This MakeMaker
  768. # writes Makefiles, that use ExtUtils::Mkbootstrap directly.
  769. sub mkbootstrap {
  770.     die <<END;
  771. !!! Your Makefile has been built such a long time ago, !!!
  772. !!! that is unlikely to work with current MakeMaker.   !!!
  773. !!! Please rebuild your Makefile                       !!!
  774. END
  775. }
  776.  
  777. # Ditto for mksymlists() as of MakeMaker 5.17
  778. sub mksymlists {
  779.     die <<END;
  780. !!! Your Makefile has been built such a long time ago, !!!
  781. !!! that is unlikely to work with current MakeMaker.   !!!
  782. !!! Please rebuild your Makefile                       !!!
  783. END
  784. }
  785.  
  786. sub neatvalue {
  787.     my($v) = @_;
  788.     return "undef" unless defined $v;
  789.     my($t) = ref $v;
  790.     return "q[$v]" unless $t;
  791.     if ($t eq 'ARRAY') {
  792.     my(@m, $elem, @neat);
  793.     push @m, "[";
  794.     foreach $elem (@$v) {
  795.         push @neat, "q[$elem]";
  796.     }
  797.     push @m, join ", ", @neat;
  798.     push @m, "]";
  799.     return join "", @m;
  800.     }
  801.     return "$v" unless $t eq 'HASH';
  802.     my(@m, $key, $val);
  803.     push(@m,"$key=>".neatvalue($val)) while (($key,$val) = each %$v);
  804.     return "{ ".join(', ',@m)." }";
  805. }
  806.  
  807. sub selfdocument {
  808.     my($self) = @_;
  809.     my(@m);
  810.     if ($Verbose){
  811.     push @m, "\n# Full list of MakeMaker attribute values:";
  812.     foreach $key (sort keys %$self){
  813.         next if $key eq 'RESULT' || $key =~ /^[A-Z][a-z]/;
  814.         my($v) = neatvalue($self->{$key});
  815.         $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
  816.         $v =~ tr/\n/ /s;
  817.         push @m, "#    $key => $v";
  818.     }
  819.     }
  820.     join "\n", @m;
  821. }
  822.  
  823. package ExtUtils::MakeMaker;
  824. 1;
  825.  
  826. # Without selfLoader we need
  827. __DATA__
  828.  
  829.  
  830. # For SelfLoader we need 
  831. # __END__ DATA
  832.  
  833.  
  834. =head1 NAME
  835.  
  836. ExtUtils::MakeMaker - create an extension Makefile
  837.  
  838. =head1 SYNOPSIS
  839.  
  840. C<use ExtUtils::MakeMaker;>
  841.  
  842. C<WriteMakefile( ATTRIBUTE =E<gt> VALUE [, ...] );>
  843.  
  844. which is really
  845.  
  846. C<MM-E<gt>new(\%att)-E<gt>flush;>
  847.  
  848. =head1 DESCRIPTION
  849.  
  850. This utility is designed to write a Makefile for an extension module
  851. from a Makefile.PL. It is based on the Makefile.SH model provided by
  852. Andy Dougherty and the perl5-porters.
  853.  
  854. It splits the task of generating the Makefile into several subroutines
  855. that can be individually overridden.  Each subroutine returns the text
  856. it wishes to have written to the Makefile.
  857.  
  858. =head2 Hintsfile support
  859.  
  860. MakeMaker.pm uses the architecture specific information from
  861. Config.pm. In addition it evaluates architecture specific hints files
  862. in a C<hints/> directory. The hints files are expected to be named
  863. like their counterparts in C<PERL_SRC/hints>, but with an C<.pl> file
  864. name extension (eg. C<next_3_2.pl>). They are simply C<eval>ed by
  865. MakeMaker within the WriteMakefile() subroutine, and can be used to
  866. execute commands as well as to include special variables. The rules
  867. which hintsfile is chosen are the same as in Configure.
  868.  
  869. The hintsfile is eval()ed immediately after the arguments given to
  870. WriteMakefile are stuffed into a hash reference $self but before this
  871. reference becomes blessed. So if you want to do the equivalent to
  872. override or create an attribute you would say something like
  873.  
  874.     $self->{LIBS} = ['-ldbm -lucb -lc'];
  875.  
  876. =head2 What's new in version 5 of MakeMaker
  877.  
  878. MakeMaker 5 is pure object oriented. This allows us to write an
  879. unlimited number of Makefiles with a single perl process. 'perl
  880. Makefile.PL' with MakeMaker 5 goes through all subdirectories
  881. immediately and evaluates any Makefile.PL found in the next level
  882. subdirectories. The benefit of this approach comes in useful for both
  883. single and multi directories extensions.
  884.  
  885. Multi directory extensions have an immediately visible speed
  886. advantage, because there's no startup penalty for any single
  887. subdirectory Makefile.
  888.  
  889. Single directory packages benefit from the much improved
  890. needs_linking() method. As the main Makefile knows everything about
  891. the subdirectories, a needs_linking() method can now query all
  892. subdirectories if there is any linking involved down in the tree. The
  893. speedup for PM-only Makefiles seems to be around 1 second on my
  894. Indy 100 MHz.
  895.  
  896. =head2 Incompatibilities between MakeMaker 5.00 and 4.23
  897.  
  898. There are no incompatibilities in the short term, as all changes are
  899. accompanied by short-term workarounds that guarantee full backwards
  900. compatibility.
  901.  
  902. You are likely to face a few warnings that expose deprecations which
  903. will result in incompatibilities in the long run:
  904.  
  905. You should not use %att directly anymore. Instead any subroutine you
  906. override in the MY package will be called by the object method, so you
  907. can access all object attributes directly via the object in $_[0].
  908.  
  909. You should not call the class methos MM->something anymore. Instead
  910. you should call the superclass. Something like
  911.  
  912.     sub MY::constants {
  913.         my $self = shift;
  914.         $self->MM::constants();
  915.     }
  916.  
  917. Especially the libscan() and exescan() methods should be altered
  918. towards OO programming, that means do not expect that $_ to contain
  919. the path but rather $_[1].
  920.  
  921. Try to build several extensions simultanously to debug your
  922. Makefile.PL. You can unpack a bunch of distributed packages within one
  923. directory and run
  924.  
  925.     perl -MExtUtils::MakeMaker -e 'WriteMakefile()'
  926.  
  927. That's actually fun to watch :)
  928.  
  929. Final suggestion: Try to delete all of your MY:: subroutines and
  930. watch, if you really still need them. MakeMaker might already do what
  931. you want without them. That's all about it.
  932.  
  933.  
  934. =head2 Default Makefile Behaviour
  935.  
  936. The automatically generated Makefile enables the user of the extension
  937. to invoke
  938.  
  939.   perl Makefile.PL # optionally "perl Makefile.PL verbose"
  940.   make
  941.   make test        # optionally set TEST_VERBOSE=1
  942.   make install     # See below
  943.  
  944. The Makefile to be produced may be altered by adding arguments of the
  945. form C<KEY=VALUE>. E.g.
  946.  
  947.   perl Makefile.PL PREFIX=/tmp/myperl5
  948.  
  949. Other interesting targets in the generated Makefile are
  950.  
  951.   make config     # to check if the Makefile is up-to-date
  952.   make clean      # delete local temp files (Makefile gets renamed)
  953.   make realclean  # delete derived files (including ./blib)
  954.   make ci         # check in all the files in the MANIFEST file
  955.   make dist       # see below the Distribution Support section
  956.  
  957. =head2 make test
  958.  
  959. MakeMaker checks for the existence of a file named "test.pl" in the
  960. current directory and if it exists it adds commands to the test target
  961. of the generated Makefile that will execute the script with the proper
  962. set of perl C<-I> options.
  963.  
  964. MakeMaker also checks for any files matching glob("t/*.t"). It will
  965. add commands to the test target of the generated Makefile that execute
  966. all matching files via the L<Test::Harness> module with the C<-I>
  967. switches set correctly.
  968.  
  969. =head2 make install
  970.  
  971. make alone puts all relevant files into directories that are named by
  972. the macros INST_LIB, INST_ARCHLIB, INST_EXE, INST_MAN1DIR, and
  973. INST_MAN3DIR. All these default to something below ./blib if
  974. you are I<not> building below the perl source directory. If you I<are>
  975. building below the perl source, INST_LIB and INST_ARCHLIB default to
  976.  ../../lib, and INST_EXE is not defined.
  977.  
  978. The I<install> target of the generated Makefile copies the files found
  979. below each of the INST_* directories to their INSTALL*
  980. counterparts. Which counterparts are chosen depends on the setting of
  981. INSTALLDIRS according to the following table:
  982.  
  983.                       INSTALLDIRS set to
  984.                               perl                 site
  985.  
  986.     INST_LIB        INSTALLPRIVLIB    INSTALLSITELIB
  987.     INST_ARCHLIB    INSTALLARCHLIB    INSTALLSITEARCH
  988.     INST_EXE                   INSTALLBIN
  989.     INST_MAN1DIR             INSTALLMAN1DIR
  990.     INST_MAN3DIR             INSTALLMAN3DIR
  991.  
  992. The INSTALL... macros in turn default to their %Config
  993. ($Config{installprivlib}, $Config{installarchlib}, etc.) counterparts.
  994.  
  995. If you don't want to keep the defaults, MakeMaker helps you to
  996. minimize the typing needed: the usual relationship between
  997. INSTALLPRIVLIB and INSTALLARCHLIB is determined by Configure at perl
  998. compilation time. MakeMaker supports the user who sets
  999. INSTALLPRIVLIB. If INSTALLPRIVLIB is set, but INSTALLARCHLIB not, then
  1000. MakeMaker defaults the latter to be the same subdirectory of
  1001. INSTALLPRIVLIB as Configure decided for the counterparts in %Config ,
  1002. otherwise it defaults to INSTALLPRIVLIB. The same relationship holds
  1003. for INSTALLSITELIB and INSTALLSITEARCH.
  1004.  
  1005. MakeMaker gives you much more freedom than needed to configure
  1006. internal variables and get different results. It is worth to mention,
  1007. that make(1) also lets you configure most of the variables that are
  1008. used in the Makefile. But in the majority of situations this will not
  1009. be necessary, and should only be done, if the author of a package
  1010. recommends it.
  1011.  
  1012.  
  1013. =head2 PREFIX attribute
  1014.  
  1015. The PREFIX attribute can be used to set the INSTALL* attributes in one
  1016. go. The quickest way to install a module in a non-standard place
  1017.  
  1018.     perl Makefile.PL PREFIX=~
  1019.  
  1020. This will replace the string specified by $Config{prefix} in all
  1021. $Config{install*} values.
  1022.  
  1023. Note, that the tilde expansion is done by MakeMaker, not by perl by
  1024. default, nor by make.
  1025.  
  1026. If the user has superuser privileges, and is not working on AFS
  1027. (Andrew File System) or relatives, then the defaults for
  1028. INSTALLPRIVLIB, INSTALLARCHLIB, INSTALLBIN, etc. will be appropriate,
  1029. and this incantation will be the best:
  1030.  
  1031.     perl Makefile.PL; make; make test
  1032.     make install
  1033.  
  1034. make install per default writes some documentation of what has been
  1035. done into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This feature
  1036. can be bypassed by calling make pure_install.
  1037.  
  1038. =head2 AFS users
  1039.  
  1040. will have to specify the installation directories as these most
  1041. probably have changed since perl itself has been installed. They will
  1042. have to do this by calling
  1043.  
  1044.     perl Makefile.PL INSTALLSITELIB=/afs/here/today \
  1045.     INSTALLBIN=/afs/there/now INSTALLMAN3DIR=/afs/for/manpages
  1046.     make
  1047.  
  1048. Be careful to repeat this procedure every time you recompile an
  1049. extension, unless you are sure the AFS installation directories are
  1050. still valid.
  1051.  
  1052. =head2 Static Linking of a new Perl Binary
  1053.  
  1054. An extension that is built with the above steps is ready to use on
  1055. systems supporting dynamic loading. On systems that do not support
  1056. dynamic loading, any newly created extension has to be linked together
  1057. with the available resources. MakeMaker supports the linking process
  1058. by creating appropriate targets in the Makefile whenever an extension
  1059. is built. You can invoke the corresponding section of the makefile with
  1060.  
  1061.     make perl
  1062.  
  1063. That produces a new perl binary in the current directory with all
  1064. extensions linked in that can be found in INST_ARCHLIB , SITELIBEXP,
  1065. and PERL_ARCHLIB. To do that, MakeMaker writes a new Makefile, on
  1066. UNIX, this is called Makefile.aperl (may be system dependent). If you
  1067. want to force the creation of a new perl, it is recommended, that you
  1068. delete this Makefile.aperl, so the directories are searched-through
  1069. for linkable libraries again.
  1070.  
  1071. The binary can be installed into the directory where perl normally
  1072. resides on your machine with
  1073.  
  1074.     make inst_perl
  1075.  
  1076. To produce a perl binary with a different name than C<perl>, either say
  1077.  
  1078.     perl Makefile.PL MAP_TARGET=myperl
  1079.     make myperl
  1080.     make inst_perl
  1081.  
  1082. or say
  1083.  
  1084.     perl Makefile.PL
  1085.     make myperl MAP_TARGET=myperl
  1086.     make inst_perl MAP_TARGET=myperl
  1087.  
  1088. In any case you will be prompted with the correct invocation of the
  1089. C<inst_perl> target that installs the new binary into INSTALLBIN.
  1090.  
  1091. make inst_perl per default writes some documentation of what has been
  1092. done into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This
  1093. can be bypassed by calling make pure_inst_perl.
  1094.  
  1095. Warning: the inst_perl: target will most probably overwrite your
  1096. existing perl binary. Use with care!
  1097.  
  1098. Sometimes you might want to build a statically linked perl although
  1099. your system supports dynamic loading. In this case you may explicitly
  1100. set the linktype with the invocation of the Makefile.PL or make:
  1101.  
  1102.     perl Makefile.PL LINKTYPE=static    # recommended
  1103.  
  1104. or
  1105.  
  1106.     make LINKTYPE=static                # works on most systems
  1107.  
  1108. =head2 Determination of Perl Library and Installation Locations
  1109.  
  1110. MakeMaker needs to know, or to guess, where certain things are
  1111. located.  Especially INST_LIB and INST_ARCHLIB (where to put the files
  1112. during the make(1) run), PERL_LIB and PERL_ARCHLIB (where to read
  1113. existing modules from), and PERL_INC (header files and C<libperl*.*>).
  1114.  
  1115. Extensions may be built either using the contents of the perl source
  1116. directory tree or from the installed perl library. The recommended way
  1117. is to build extensions after you have run 'make install' on perl
  1118. itself. You can do that in any directory on your hard disk that is not
  1119. below the perl source tree. The support for extensions below the ext
  1120. directory of the perl distribution is only good for the standard
  1121. extensions that come with perl.
  1122.  
  1123. If an extension is being built below the C<ext/> directory of the perl
  1124. source then MakeMaker will set PERL_SRC automatically (e.g.,
  1125. C<../..>).  If PERL_SRC is defined and the extension is recognized as
  1126. a standard extension, then other variables default to the following:
  1127.  
  1128.   PERL_INC     = PERL_SRC
  1129.   PERL_LIB     = PERL_SRC/lib
  1130.   PERL_ARCHLIB = PERL_SRC/lib
  1131.   INST_LIB     = PERL_LIB
  1132.   INST_ARCHLIB = PERL_ARCHLIB
  1133.  
  1134. If an extension is being built away from the perl source then MakeMaker
  1135. will leave PERL_SRC undefined and default to using the installed copy
  1136. of the perl library. The other variables default to the following:
  1137.  
  1138.   PERL_INC     = $archlibexp/CORE
  1139.   PERL_LIB     = $privlibexp
  1140.   PERL_ARCHLIB = $archlibexp
  1141.   INST_LIB     = ./blib/lib
  1142.   INST_ARCHLIB = ./blib/arch
  1143.  
  1144. If perl has not yet been installed then PERL_SRC can be defined on the
  1145. command line as shown in the previous section.
  1146.  
  1147. =head2 Useful Default Makefile Macros
  1148.  
  1149. FULLEXT = Pathname for extension directory (eg DBD/Oracle).
  1150.  
  1151. BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
  1152.  
  1153. ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
  1154.  
  1155. INST_LIBDIR = C<$(INST_LIB)$(ROOTEXT)>
  1156.  
  1157. INST_AUTODIR = C<$(INST_LIB)/auto/$(FULLEXT)>
  1158.  
  1159. INST_ARCHAUTODIR = C<$(INST_ARCHLIB)/auto/$(FULLEXT)>
  1160.  
  1161. =head2 Using Attributes and Parameters
  1162.  
  1163. The following attributes can be specified as arguments to WriteMakefile()
  1164. or as NAME=VALUE pairs on the command line:
  1165.  
  1166. =cut
  1167.  
  1168. # The following "=item C" is used by the attrib_help routine
  1169. # likewise the "=back" below. So be careful when changing it!
  1170.  
  1171. =over 2
  1172.  
  1173. =item C
  1174.  
  1175. Ref to array of *.c file names. Initialised from a directory scan
  1176. and the values portion of the XS attribute hash. This is not
  1177. currently used by MakeMaker but may be handy in Makefile.PLs.
  1178.  
  1179. =item CONFIG
  1180.  
  1181. Arrayref. E.g. [qw(archname manext)] defines ARCHNAME & MANEXT from
  1182. config.sh. MakeMaker will add to CONFIG the following values anyway:
  1183. ar
  1184. cc
  1185. cccdlflags
  1186. ccdlflags
  1187. dlext
  1188. dlsrc
  1189. ld
  1190. lddlflags
  1191. ldflags
  1192. libc
  1193. lib_ext
  1194. obj_ext
  1195. ranlib
  1196. sitelibexp
  1197. sitearchexp
  1198. so
  1199.  
  1200. =item CONFIGURE
  1201.  
  1202. CODE reference. The subroutine should return a hash reference. The
  1203. hash may contain further attributes, e.g. {LIBS => ...}, that have to
  1204. be determined by some evaluation method.
  1205.  
  1206. =item DEFINE
  1207.  
  1208. Something like C<"-DHAVE_UNISTD_H">
  1209.  
  1210. =item DIR
  1211.  
  1212. Ref to array of subdirectories containing Makefile.PLs e.g. [ 'sdbm'
  1213. ] in ext/SDBM_File
  1214.  
  1215. =item DISTNAME
  1216.  
  1217. Your name for distributing the package (by tar file). This defaults to
  1218. NAME above.
  1219.  
  1220. =item DL_FUNCS
  1221.  
  1222. Hashref of symbol names for routines to be made available as
  1223. universal symbols.  Each key/value pair consists of the package name
  1224. and an array of routine names in that package.  Used only under AIX
  1225. (export lists) and VMS (linker options) at present.  The routine
  1226. names supplied will be expanded in the same way as XSUB names are
  1227. expanded by the XS() macro.  Defaults to
  1228.  
  1229.   {"$(NAME)" => ["boot_$(NAME)" ] }
  1230.  
  1231. e.g.
  1232.  
  1233.   {"RPC" => [qw( boot_rpcb rpcb_gettime getnetconfigent )],
  1234.    "NetconfigPtr" => [ 'DESTROY'] }
  1235.  
  1236. =item DL_VARS
  1237.  
  1238. Array of symbol names for variables to be made available as
  1239. universal symbols.  Used only under AIX (export lists) and VMS
  1240. (linker options) at present.  Defaults to [].  (e.g. [ qw(
  1241. Foo_version Foo_numstreams Foo_tree ) ])
  1242.  
  1243. =item EXE_FILES
  1244.  
  1245. Ref to array of executable files. The files will be copied to the
  1246. INST_EXE directory. Make realclean will delete them from there
  1247. again.
  1248.  
  1249. =item FIRST_MAKEFILE
  1250.  
  1251. The name of the Makefile to be produced. Defaults to the contents of
  1252. MAKEFILE, but can be overridden. This is used for the second Makefile
  1253. that will be produced for the MAP_TARGET.
  1254.  
  1255. =item FULLPERL
  1256.  
  1257. Perl binary able to run this extension.
  1258.  
  1259. =item H
  1260.  
  1261. Ref to array of *.h file names. Similar to C.
  1262.  
  1263. =item INC
  1264.  
  1265. Include file dirs eg: C<"-I/usr/5include -I/path/to/inc">
  1266.  
  1267. =item INSTALLARCHLIB
  1268.  
  1269. Used by 'make install', which copies files from INST_ARCHLIB to this
  1270. directory if INSTALLDIRS is set to perl.
  1271.  
  1272. =item INSTALLBIN
  1273.  
  1274. Used by 'make install' which copies files from INST_EXE to this
  1275. directory.
  1276.  
  1277. =item INSTALLDIRS
  1278.  
  1279. Determines which of the two sets of installation directories to
  1280. choose: installprivlib and installarchlib versus installsitelib and
  1281. installsitearch. The first pair is chosen with INSTALLDIRS=perl, the
  1282. second with INSTALLDIRS=site. Default is site.
  1283.  
  1284. =item INSTALLMAN1DIR
  1285.  
  1286. This directory gets the man pages at 'make install' time. Defaults to
  1287. $Config{installman1dir}.
  1288.  
  1289. =item INSTALLMAN3DIR
  1290.  
  1291. This directory gets the man pages at 'make install' time. Defaults to
  1292. $Config{installman3dir}.
  1293.  
  1294. =item INSTALLPRIVLIB
  1295.  
  1296. Used by 'make install', which copies files from INST_LIB to this
  1297. directory if INSTALLDIRS is set to perl.
  1298.  
  1299. =item INSTALLSITELIB
  1300.  
  1301. Used by 'make install', which copies files from INST_LIB to this
  1302. directory if INSTALLDIRS is set to site (default).
  1303.  
  1304. =item INSTALLSITEARCH
  1305.  
  1306. Used by 'make install', which copies files from INST_ARCHLIB to this
  1307. directory if INSTALLDIRS is set to site (default).
  1308.  
  1309. =item INST_ARCHLIB
  1310.  
  1311. Same as INST_LIB for architecture dependent files.
  1312.  
  1313. =item INST_EXE
  1314.  
  1315. Directory, where executable scripts should be installed during
  1316. 'make'. Defaults to "./blib/bin", just to have a dummy location during
  1317. testing. make install will copy the files in INST_EXE to INSTALLBIN.
  1318.  
  1319. =item INST_LIB
  1320.  
  1321. Directory where we put library files of this extension while building
  1322. it.
  1323.  
  1324. =item INST_MAN1DIR
  1325.  
  1326. Directory to hold the man pages at 'make' time
  1327.  
  1328. =item INST_MAN3DIR
  1329.  
  1330. Directory to hold the man pages at 'make' time
  1331.  
  1332. =item LDFROM
  1333.  
  1334. defaults to "$(OBJECT)" and is used in the ld command to specify
  1335. what files to link/load from (also see dynamic_lib below for how to
  1336. specify ld flags)
  1337.  
  1338. =item LIBPERL_A
  1339.  
  1340. The filename of the perllibrary that will be used together with this
  1341. extension. Defaults to libperl.a.
  1342.  
  1343. =item LIBS
  1344.  
  1345. An anonymous array of alternative library
  1346. specifications to be searched for (in order) until
  1347. at least one library is found. E.g.
  1348.  
  1349.   'LIBS' => ["-lgdbm", "-ldbm -lfoo", "-L/path -ldbm.nfs"]
  1350.  
  1351. Mind, that any element of the array
  1352. contains a complete set of arguments for the ld
  1353. command. So do not specify
  1354.  
  1355.   'LIBS' => ["-ltcl", "-ltk", "-lX11"]
  1356.  
  1357. See ODBM_File/Makefile.PL for an example, where an array is needed. If
  1358. you specify a scalar as in
  1359.  
  1360.   'LIBS' => "-ltcl -ltk -lX11"
  1361.  
  1362. MakeMaker will turn it into an array with one element.
  1363.  
  1364. =item LINKTYPE
  1365.  
  1366. 'static' or 'dynamic' (default unless usedl=undef in
  1367. config.sh). Should only be used to force static linking (also see
  1368. linkext below).
  1369.  
  1370. =item MAKEAPERL
  1371.  
  1372. Boolean which tells MakeMaker, that it should include the rules to
  1373. make a perl. This is handled automatically as a switch by
  1374. MakeMaker. The user normally does not need it.
  1375.  
  1376. =item MAKEFILE
  1377.  
  1378. The name of the Makefile to be produced.
  1379.  
  1380. =item MAN1PODS
  1381.  
  1382. Hashref of pod-containing files. MakeMaker will default this to all
  1383. EXE_FILES files that include POD directives. The files listed
  1384. here will be converted to man pages and installed as was requested
  1385. at Configure time.
  1386.  
  1387. =item MAN3PODS
  1388.  
  1389. Hashref of .pm and .pod files. MakeMaker will default this to all
  1390.  .pod and any .pm files that include POD directives. The files listed
  1391. here will be converted to man pages and installed as was requested
  1392. at Configure time.
  1393.  
  1394. =item MAP_TARGET
  1395.  
  1396. If it is intended, that a new perl binary be produced, this variable
  1397. may hold a name for that binary. Defaults to perl
  1398.  
  1399. =item MYEXTLIB
  1400.  
  1401. If the extension links to a library that it builds set this to the
  1402. name of the library (see SDBM_File)
  1403.  
  1404. =item NAME
  1405.  
  1406. Perl module name for this extension (DBD::Oracle). This will default
  1407. to the directory name but should be explicitly defined in the
  1408. Makefile.PL.
  1409.  
  1410. =item NEEDS_LINKING
  1411.  
  1412. MakeMaker will figure out, if an extension contains linkable code
  1413. anywhere down the directory tree, and will set this variable
  1414. accordingly, but you can speed it up a very little bit, if you define
  1415. this boolean variable yourself.
  1416.  
  1417. =item NOECHO
  1418.  
  1419. Defaults the C<@>. By setting it to an empty string you can generate a
  1420. Makefile that echos all commands. Mainly used in debugging MakeMaker
  1421. itself.
  1422.  
  1423. =item NORECURS
  1424.  
  1425. Boolean.  Attribute to inhibit descending into subdirectories.
  1426.  
  1427. =item OBJECT
  1428.  
  1429. List of object files, defaults to '$(BASEEXT)$(OBJ_EXT)', but can be a long
  1430. string containing all object files, e.g. "tkpBind.o
  1431. tkpButton.o tkpCanvas.o"
  1432.  
  1433. =item PERL
  1434.  
  1435. Perl binary for tasks that can be done by miniperl
  1436.  
  1437. =item PERLMAINCC
  1438.  
  1439. The call to the program that is able to compile perlmain.c. Defaults
  1440. to $(CC).
  1441.  
  1442. =item PERL_ARCHLIB
  1443.  
  1444. Same as above for architecture dependent files
  1445.  
  1446. =item PERL_LIB
  1447.  
  1448. Directory containing the Perl library to use.
  1449.  
  1450. =item PERL_SRC
  1451.  
  1452. Directory containing the Perl source code (use of this should be
  1453. avoided, it may be undefined)
  1454.  
  1455. =item PL_FILES
  1456.  
  1457. Ref to hash of files to be processed as perl programs. MakeMaker
  1458. will default to any found *.PL file (except Makefile.PL) being keys
  1459. and the basename of the file being the value. E.g.
  1460.  
  1461.   {'foobar.PL' => 'foobar'}
  1462.  
  1463. The *.PL files are expected to produce output to the target files
  1464. themselves.
  1465.  
  1466. =item PM
  1467.  
  1468. Hashref of .pm files and *.pl files to be installed.  e.g.
  1469.  
  1470.   {'name_of_file.pm' => '$(INST_LIBDIR)/install_as.pm'}
  1471.  
  1472. By default this will include *.pm and *.pl. If a lib directory
  1473. exists and is not listed in DIR (above) then any *.pm and *.pl files
  1474. it contains will also be included by default.  Defining PM in the
  1475. Makefile.PL will override PMLIBDIRS.
  1476.  
  1477. =item PMLIBDIRS
  1478.  
  1479. Ref to array of subdirectories containing library files.  Defaults to
  1480. [ 'lib', $(BASEEXT) ]. The directories will be scanned and any files
  1481. they contain will be installed in the corresponding location in the
  1482. library.  A libscan() method can be used to alter the behaviour.
  1483. Defining PM in the Makefile.PL will override PMLIBDIRS.
  1484.  
  1485. =item PREFIX
  1486.  
  1487. Can be used to set the three INSTALL* attributes in one go (except for
  1488. probably INSTALLMAN1DIR, if it is not below PREFIX according to
  1489. %Config).  They will have PREFIX as a common directory node and will
  1490. branch from that node into lib/, lib/ARCHNAME or whatever Configure
  1491. decided at the build time of your perl (unless you override one of
  1492. them, of course).
  1493.  
  1494. =item PREREQ
  1495.  
  1496. Placeholder, not yet implemented. Will eventually be a hashref: Names
  1497. of modules that need to be available to run this extension (e.g. Fcntl
  1498. for SDBM_File) are the keys of the hash and the desired version is the
  1499. value. Needs further evaluation, should probably allow to define
  1500. prerequisites among header files, libraries, perl version, etc.
  1501.  
  1502. =item SKIP
  1503.  
  1504. Arryref. E.g. [qw(name1 name2)] skip (do not write) sections of the
  1505. Makefile
  1506.  
  1507. =item TYPEMAPS
  1508.  
  1509. Ref to array of typemap file names.  Use this when the typemaps are
  1510. in some directory other than the current directory or when they are
  1511. not named B<typemap>.  The last typemap in the list takes
  1512. precedence.  A typemap in the current directory has highest
  1513. precedence, even if it isn't listed in TYPEMAPS.  The default system
  1514. typemap has lowest precedence.
  1515.  
  1516. =item VERSION
  1517.  
  1518. Your version number for distributing the package.  This defaults to
  1519. 0.1.
  1520.  
  1521. =item VERSION_FROM
  1522.  
  1523. Instead of specifying the VERSION in the Makefile.PL you can let
  1524. MakeMaker parse a file to determine the version number. The parsing
  1525. routine requires that the file named by VERSION_FROM contains one
  1526. single line to compute the version number. The first line in the file
  1527. that contains the regular expression
  1528.  
  1529.     /(\$[\w:]*\bVERSION)\b.*=/
  1530.  
  1531. will be evaluated with eval() and the value of the named variable
  1532. B<after> the eval() will be assigned to the VERSION attribute of the
  1533. MakeMaker object. The following lines will be parsed o.k.:
  1534.  
  1535.     $VERSION = '1.00';
  1536.     ( $VERSION ) = '$Revision: 1.174 $ ' =~ /\$Revision:\s+([^\s]+)/;
  1537.     $FOO::VERSION = '1.10';
  1538.  
  1539. but these will fail:
  1540.  
  1541.     my $VERSION = '1.01';
  1542.     local $VERSION = '1.02';
  1543.     local $FOO::VERSION = '1.30';
  1544.  
  1545. The file named in VERSION_FROM is added as a dependency to Makefile to
  1546. guarantee, that the Makefile contains the correct VERSION macro after
  1547. a change of the file.
  1548.  
  1549. =item XS
  1550.  
  1551. Hashref of .xs files. MakeMaker will default this.  e.g.
  1552.  
  1553.   {'name_of_file.xs' => 'name_of_file.c'}
  1554.  
  1555. The .c files will automatically be included in the list of files
  1556. deleted by a make clean.
  1557.  
  1558. =item XSOPT
  1559.  
  1560. String of options to pass to xsubpp.  This might include C<-C++> or
  1561. C<-extern>.  Do not include typemaps here; the TYPEMAP parameter exists for
  1562. that purpose.
  1563.  
  1564. =item XSPROTOARG
  1565.  
  1566. May be set to an empty string, which is identical to C<-prototypes>, or
  1567. C<-noprototypes>. See the xsubpp documentation for details. MakeMaker
  1568. defaults to the empty string.
  1569.  
  1570. =item XS_VERSION
  1571.  
  1572. Your version number for the .xs file of this package.  This defaults
  1573. to the value of the VERSION attribute.
  1574.  
  1575. =back
  1576.  
  1577. =head2 Additional lowercase attributes
  1578.  
  1579. can be used to pass parameters to the methods which implement that
  1580. part of the Makefile. These are not normally required:
  1581.  
  1582. =over 2
  1583.  
  1584. =item clean
  1585.  
  1586.   {FILES => "*.xyz foo"}
  1587.  
  1588. =item depend
  1589.  
  1590.   {ANY_TARGET => ANY_DEPENDECY, ...}
  1591.  
  1592. =item dist
  1593.  
  1594.   {TARFLAGS => 'cvfF', COMPRESS => 'gzip', SUFFIX => 'gz',
  1595.   SHAR => 'shar -m', DIST_CP => 'ln'}
  1596.  
  1597. If you specify COMPRESS, then SUFFIX should also be altered, as it is
  1598. needed to tell make the target file of the compression. Setting
  1599. DIST_CP to ln can be useful, if you need to preserve the timestamps on
  1600. your files. DIST_CP can take the values 'cp', which copies the file,
  1601. 'ln', which links the file, and 'best' which copies symbolic links and
  1602. links the rest. Default is 'best'.
  1603.  
  1604. =item dynamic_lib
  1605.  
  1606.   {ARMAYBE => 'ar', OTHERLDFLAGS => '...', INST_DYNAMIC_DEP => '...'}
  1607.  
  1608. =item installpm
  1609.  
  1610.   {SPLITLIB => '$(INST_LIB)' (default) or '$(INST_ARCHLIB)'}
  1611.  
  1612. =item linkext
  1613.  
  1614.   {LINKTYPE => 'static', 'dynamic' or ''}
  1615.  
  1616. NB: Extensions that have nothing but *.pm files had to say
  1617.  
  1618.   {LINKTYPE => ''}
  1619.  
  1620. with Pre-5.0 MakeMakers. Since version 5.00 of MakeMaker such a line
  1621. can be deleted safely. MakeMaker recognizes, when there's nothing to
  1622. be linked.
  1623.  
  1624. =item macro
  1625.  
  1626.   {ANY_MACRO => ANY_VALUE, ...}
  1627.  
  1628. =item realclean
  1629.  
  1630.   {FILES => '$(INST_ARCHAUTODIR)/*.xyz'}
  1631.  
  1632. =item tool_autosplit
  1633.  
  1634.   {MAXLEN =E<gt> 8}
  1635.  
  1636. =back
  1637.  
  1638. =cut
  1639.  
  1640. # bug in pod2html, so leave the =back
  1641.  
  1642. # Don't delete this cut, MM depends on it!
  1643.  
  1644. =head2 Overriding MakeMaker Methods
  1645.  
  1646. If you cannot achieve the desired Makefile behaviour by specifying
  1647. attributes you may define private subroutines in the Makefile.PL.
  1648. Each subroutines returns the text it wishes to have written to
  1649. the Makefile. To override a section of the Makefile you can
  1650. either say:
  1651.  
  1652.     sub MY::c_o { "new literal text" }
  1653.  
  1654. or you can edit the default by saying something like:
  1655.  
  1656.     sub MY::c_o {
  1657.         my $self = shift;
  1658.         local *c_o;
  1659.             $_=$self->MM::c_o;
  1660.         s/old text/new text/;
  1661.         $_;
  1662.     }
  1663.  
  1664. Both methods above are available for backwards compatibility with
  1665. older Makefile.PLs.
  1666.  
  1667. If you still need a different solution, try to develop another
  1668. subroutine, that fits your needs and submit the diffs to
  1669. F<perl5-porters@nicoh.com> or F<comp.lang.perl.misc> as appropriate.
  1670.  
  1671. =head2 Distribution Support
  1672.  
  1673. For authors of extensions MakeMaker provides several Makefile
  1674. targets. Most of the support comes from the ExtUtils::Manifest module,
  1675. where additional documentation can be found.
  1676.  
  1677. =over 4
  1678.  
  1679. =item    make distcheck
  1680.  
  1681. reports which files are below the build directory but not in the
  1682. MANIFEST file and vice versa. (See ExtUtils::Manifest::fullcheck() for
  1683. details)
  1684.  
  1685. =item    make skipcheck
  1686.  
  1687. reports which files are skipped due to the entries in the
  1688. C<MANIFEST.SKIP> file (See ExtUtils::Manifest::skipcheck() for
  1689. details)
  1690.  
  1691. =item    make distclean
  1692.  
  1693. does a realclean first and then the distcheck. Note that this is not
  1694. needed to build a new distribution as long as you are sure, that the
  1695. MANIFEST file is ok.
  1696.  
  1697. =item    make manifest
  1698.  
  1699. rewrites the MANIFEST file, adding all remaining files found (See
  1700. ExtUtils::Manifest::mkmanifest() for details)
  1701.  
  1702. =item    make distdir
  1703.  
  1704. Copies all the files that are in the MANIFEST file to a newly created
  1705. directory with the name C<$(DISTNAME)-$(VERSION)>. If that directory
  1706. exists, it will be removed first.
  1707.  
  1708. =item    make disttest
  1709.  
  1710. Makes a distdir first, and runs a C<perl Makefile.PL>, a make, and
  1711. a make test in that directory.
  1712.  
  1713. =item    make tardist
  1714.  
  1715. First does a command $(PREOP) which defaults to a null command. Does a
  1716. distdir next and runs C<tar> on that directory into a tarfile. Then
  1717. deletes the distdir. Finishes with a command $(POSTOP) which defaults
  1718. to a null command.
  1719.  
  1720. =item    make dist
  1721.  
  1722. Defaults to $(DIST_DEFAULT) which in turn defaults to tardist.
  1723.  
  1724. =item    make uutardist
  1725.  
  1726. Runs a tardist first and uuencodes the tarfile.
  1727.  
  1728. =item    make shdist
  1729.  
  1730. First does a command $(PREOP) which defaults to a null command. Does a
  1731. distdir next and runs C<shar> on that directory into a sharfile. Then
  1732. deletes the distdir. Finishes with a command $(POSTOP) which defaults
  1733. to a null command.  Note: For shdist to work properly a C<shar>
  1734. program that can handle directories is mandatory.
  1735.  
  1736. =item    make ci
  1737.  
  1738. Does a $(CI) and a $(RCS_LABEL) on all files in the MANIFEST file.
  1739.  
  1740. =back
  1741.  
  1742. Customization of the dist targets can be done by specifying a hash
  1743. reference to the dist attribute of the WriteMakefile call. The
  1744. following parameters are recognized:
  1745.  
  1746.     CI           ('ci -u')
  1747.     COMPRESS     ('compress')
  1748.     POSTOP       ('@ :')
  1749.     PREOP        ('@ :')
  1750.     RCS_LABEL    ('rcs -q -Nv$(VERSION_SYM):')
  1751.     SHAR         ('shar')
  1752.     SUFFIX       ('Z')
  1753.     TAR          ('tar')
  1754.     TARFLAGS     ('cvf')
  1755.  
  1756. An example:
  1757.  
  1758.     WriteMakefile( 'dist' => { COMPRESS=>"gzip", SUFFIX=>"gz" })
  1759.  
  1760.  
  1761. =head1 AUTHORS
  1762.  
  1763. Andy Dougherty F<E<lt>doughera@lafcol.lafayette.eduE<gt>>, Andreas
  1764. KE<ouml>nig F<E<lt>A.Koenig@franz.ww.TU-Berlin.DEE<gt>>, Tim Bunce
  1765. F<E<lt>Tim.Bunce@ig.co.ukE<gt>>.  VMS support by Charles Bailey
  1766. F<E<lt>bailey@genetics.upenn.eduE<gt>>. OS/2 support by Ilya
  1767. Zakharevich F<E<lt>ilya@math.ohio-state.eduE<gt>>. Contact the
  1768. makemaker mailing list C<mailto:makemaker@franz.ww.tu-berlin.de>, if
  1769. you have any questions.
  1770.  
  1771. =head1 MODIFICATION HISTORY
  1772.  
  1773. For a more complete documentation see the file Changes in the
  1774. MakeMaker distribution package.
  1775.  
  1776. =head1 TODO
  1777.  
  1778. See the file Todo in the MakeMaker distribution package.
  1779.  
  1780. =cut
  1781.